<?php

namespace app\admin\controller\channel;

use app\admin\controller\AdminController;
use app\admin\service\channel\WxopenService;
use think\response\Json;

class Wxopen extends AdminController
{
    /**
     * 获取微信开放平台渠道配置
     * @return Json
     */
    public function getWxopenConfig()
    {
        $result = WxopenService::getWxopenConfig();
        return $this->data($result);
    }

    /**
     * 设置微信开放平台渠道配置
     * @return Json
     */
    public function setWxopenConfig()
    {
        $params = $this->postData([
            ['app_id', ''],
            ['app_secret', ''],
        ]);

        $result = WxopenService::setWxopenConfig($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WxopenService::getError());
        }
    }
}